package com.gadgets.framework.common.dto;

import com.gadgets.framework.common.constant.GadgetsConstant;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author UncleXiu
 * @version V1.0.0
 * @data 2020-09-16
 * 
 */
public class HttpBaseResp<T> implements Serializable {

    public HttpBaseResp() {
        // 默认是执行成功
        retCode = GadgetsConstant.RESP_CODE.SUCCESS_CODE;
    }

    public HttpBaseResp(List<T> resultData, Pagination paging) {
        // 默认是执行成功
        retCode = GadgetsConstant.RESP_CODE.SUCCESS_CODE;

        this.resultData = resultData;
        this.paging = paging;
    }

    public HttpBaseResp(T resultData, Pagination paging) {
        // 默认是执行成功
        retCode = GadgetsConstant.RESP_CODE.SUCCESS_CODE;

        this.resultData = new ArrayList<>();
        this.resultData.add(resultData);
        this.paging = paging;
    }

    public static final long SerializableUID = 0L;
    /**
     * 应答码
     */
    private String retCode;
    /**
     * 异常等级
     */
    private int errorLevel;
    /**
     * 错误信息
     */
    private String errorMsg;
    /**
     * 应答信息
     */
    private List<T> resultData;
    /**
     * 分页对象
     */
    private Pagination paging;

    public String getRetCode() {
        return retCode;
    }

    public void setRetCode(String retCode) {
        this.retCode = retCode;
    }

    public int getErrorLevel() {
        return errorLevel;
    }

    public void setErrorLevel(int errorLevel) {
        this.errorLevel = errorLevel;
    }

    public String getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    public List<T> getResultData() {
        return resultData;
    }

    public void setResultData(List<T> resultData) {
        this.resultData = resultData;
    }

    public Pagination getPaging() {
        return paging;
    }

    public void setPaging(Pagination paging) {
        this.paging = paging;
    }

    public int size(){
        if(null!=resultData){
            return resultData.size();
        }
        return -1;
    }

}
